/* GUI CONVERTED from wccapnxt.p (converter v1.75) Sat Aug 12 16:32:08 2000 */
/* wccapnxt.p - SEARCH FOR NEXT AVAILABLE WORK CENTER CAPACITY          */
/* Copyright 1986-2000 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*L102*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 7.0      LAST MODIFIED: 06/02/92    BY: RAM  *F740*          */
/* REVISION: 7.3      LAST MODIFIED: 07/24/96    BY: *G2C4* evan bishop   */
/* REVISION: 8.6e     LAST MODIFIED: 07/04/00    BY: *L102* Vandna Rohira */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00    BY: *N0KC* myb           */


/* PARAMETERS:                                                   */
/* wosite    work order site                                     */
/* wrwkctr   work order routing work center                      */
/* wosite    work order routing machine                          */
/* nxtdate   date from which to search for capacity              */
/* nxtincr   increment of search (e.g. 1 or -1)                  */
/* nxtcap    decimal variable used to return capacity in hours   */
/* nxterr    logical variable used to return error flag if no    */
/*           capacity is found in shop_cal (in 365 days)         */

/* NOTE: If nxtdate is unknown, 0 is returned in nxtcap.         */

/*L102*/ /* MFDECLRE.I DEFINES ALL GLOBAL VARIABLES */
/*L102*/ {mfdeclre.i}

/*L102** /*G2C4*/ {mfglobal.i} */

/*G2C4*/ define input parameter wosite  as character no-undo.
/*G2C4*/ define input parameter wrwkctr as character no-undo.
/*G2C4*/ define input parameter wrmch   as character no-undo.

     define input-output parameter nxtdate as date no-undo.
     define input parameter nxtincr as integer no-undo.
     define output parameter nxtcap as decimal initial 0 no-undo.
     define output parameter nxterr like mfc_logical initial no no-undo.

/*G2C4*  define shared variable wosite  like wo_site.
      *  define shared variable wrwkctr like wr_wkctr.
      *  define shared variable wrmch   like wr_mch.
**G2C4*/
     define variable chkdate as date no-undo.
/*G2C4*/ define variable original_date as date no-undo.

/*L102** /*G2C4*/ {msgvar.i} */

/*G2C4*  {mfdeclre.i} */

/*G2C4*/ if nxtdate = ? or nxtincr = 0 then return.

     /* Find shop calendar record to use for site/workcenter/machine */
     {wccal.i &site=wosite &wkctr=wrwkctr &mch=wrmch}

/*G2C4*  if nxtdate <> ? and nxtincr <> 0 and available shop_cal then do: */
/*G2C4*/ if available shop_cal then do:

/*G2C4*/    /* Added section */
        if  shop_wdays[1] = no
        and shop_wdays[2] = no
        and shop_wdays[3] = no
        and shop_wdays[4] = no
        and shop_wdays[5] = no
        and shop_wdays[6] = no
        and shop_wdays[7] = no
        then do:
           pause 0.
           hide message no-pause.
           {mfmsg03.i 411 4 wosite wrwkctr wrmch}
           nxterr = yes.
           return.
        end.
/*G2C4*/    /* End of added section */

        if nxtincr > 0 then
           chkdate = nxtdate + 365.
        else
           chkdate = nxtdate - 365.

/*G2C4*/    original_date = nxtdate.

        do while nxtcap = 0:

           if (nxtincr > 0 and nxtdate > chkdate)
           or (nxtincr < 0 and nxtdate < chkdate)
           then do:
          pause 0.
          hide message no-pause.

/*G2C4*           {mfmsg03.i 411 4 shop_site shop_wkctr shop_mch} */
/*G2C4*/          {mfmsg03.i 411 4 wosite wrwkctr wrmch}

          nxterr = yes.
/*G2C4*/          nxtdate = original_date.
          undo, return.
           end.

           nxtdate = nxtdate + nxtincr.

/*L102*/   /* THE CONDITION BELOW IS ADDED TO IGNORE EXCEPTIONS IN THE      */
/*L102*/   /* CALENDAR FOR CALCULATION OF LEAD TIME IN ROUTING COST ROLL-UP */

/*L102*/   if execname <> "rwroru.p" then do:

              {wccapday.i &date=nxtdate &caphrs=nxtcap}

/*L102*/   end. /* IF EXECNAME <> "RWRORU.P" */
/*L102*/   else do:
/*L102*/      if shop_wday[weekday(nxtdate)] = yes then
/*L102*/         nxtcap = shop_hours[weekday(nxtdate)].
/*L102*/   end. /* EXECNAME = "RWRORU.P" */

        end.  /* do while nxtcap = 0 */
     end.  /* available shop_cal */
